# 从文本中获取数据：
from math import sqrt
import numpy as np


# 从文本中获取数据
def getDataFromText():
    dataOrigin = open("static/data.text", "r", encoding="utf-8").readlines()
    data = []
    for i in dataOrigin:
        data.append(i.split("\n")[0].split(":")[1].split("米")[0])
    return data


# 将所得的数据列表变成一个n阶方阵
def dataToMatrix(data):
    longth = len(data)
    n=sqrt(longth)
    n=int(n)
    matrix = np.ones((n, n))
    for j in range(0, n):
        for m in range(0, n):
            matrix[j, m]=data[j*n+m]
    return matrix